<html>
<head>
    <title>Refresh Content</title>
    <link rel="stylesheet" type="text/css" href="/ext-3.3.1/resources/css/ext-all.css">
    <link rel="stylesheet" type="text/css" href="/ext-3.3.1/examples/shared/examples.css"/>
    <script type="text/javascript" src="/ext-3.3.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="/ext-3.3.1/ext-all.js"></script>
    <script type="text/javascript" src="/html/js/topbar.js"></script>
    <script type="text/javascript" src="/addama/ui/query_parameters.js"></script>
    <script type="text/javascript">
        Ext.onReady(function() {
            var newButton = function(title, uri) {
                return new Ext.Button({
                    text: "Refresh " + title,
                    handler: function() {
                        Ext.MessageBox.show({
                            msg: "Refreshing " + title + "...",
                            width:300,
                            wait:true,
                            waitConfig: {interval:200}
                        });

                        Ext.Ajax.request({
                            url: uri,
                            method: "POST",
                            success: function() {
                                setTimeout("Ext.MessageBox.hide();", 1000);
                            },
                            failure: function(o) {
                                setTimeout("Ext.MessageBox.hide();", 1000);
                                Ext.MessageBox.alert('Refreshing ' + title, 'Danger Will Robinson!!!: ' + o.statusMessage);
                            }
                        });
                    }
                });
            };
            
            new TopBarViewPort({
                getPanels: function() {
                    var panel = new Ext.Panel({
                        region: "center",
                        width: '100%',
                        height: '100%',
                        items: [
                            newButton("Addama UI", "/addama/ui/refresh"),
                            newButton("ExtJS", "/ext-3.3.1/refresh"),
                            newButton("Teacher Depot UI", "/html/refresh")
                        ]
                    });

                    return [panel];
                }
            });
        });
    </script>
</head>
<body>
</body>
</html>
